import React from "react";
import { Button, message, Popconfirm } from "antd";
import axios from "axios";

function DeleteBooks(derecord) {
  
   //删除确认回调
   async function confirm(){
    console.log(derecord,derecord.derecord.id);
    const res = await axios.get(`http://localhost:7001/deletebooks?deleteid=${derecord.derecord.id}`);
    console.log('111',res);
    if(res.status===200){
       // 成功信息提示
    setTimeout(() => {
      message.success({ content: '删除成功', duration: 1 });
    }, 500);
    }
  }
  //删除取消回调
  function cancel(){
    console.log();
    message.error('已取消')
  }

  return(
    <>
    <Popconfirm
              title="确认删除书籍吗?"
              onConfirm={confirm}
              onCancel={cancel}
              okText="Yes"
              cancelText="No"
            >
              <Button type="primary" shape="round" danger >删除</Button>
            </Popconfirm>
            </>
  )
}

export default DeleteBooks;
